<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ page import="com.ysd.entity.YongHu"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改密码</title>
<link rel="stylesheet" href="/wk2un10/houtai/lib/layui/css/layui.css">
</head>
<body>
<%
HttpSession s = request.getSession();
YongHu y = (YongHu) s.getAttribute("user");//获取session数据
%>
<form class="layui-form" action="">
<div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" name="name"  value="<%=y.getName() %>" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="password" name="pwd" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
       <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
    </div>
  </div>
  </form>
  <script type="text/javascript" src="/wk2un10/houtai/lib/layui/layui.all.js"></script>
  <script type="text/javascript" src="/wk2un10/houtai/lib/layui/layui.js"></script>
		<script>
			//Demo
			layui.use('form', function() {
				var form = layui.form;
				var $ = layui.jquery; //引入jquery
				form.on('submit(formDemo)', function(data) {
					var d = data.field; //表单中的数据，定义一个对象来接收
					//通过ajax向数据库提交数据了
					d.method="update";
					console.log(d); //提交之前的一个数据验证、通过打印的方式先手动的去判断一下这个数据
					var url ='/wk2un10/pwdsqlServlet';//地址不对
					//确保数据没有问题就进行ajax提交了
					$.post(url, d,
						function(data) {
							if(data.count>0){//对应Result里面的count
								console.log('修改成功');
								layer.msg('修改成功'); 
							}
						}, "json");
					return false;
				});
			});
		</script>
  </body>
</html>